package Draw;

class fright implements Runnable{
    private int x;
    private int y;
    int speed=5;
    private int direct;
    boolean loop=true;
    public fright(int x, int y, int direct) {
        this.x = x;
        this.y = y;
        this.direct = direct;
    }
    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    @Override
    public void run() {
        while (loop){
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        switch (direct) {
            case 0:
                y -= speed;
                break;
            case 1:
                x += speed;
                break;
            case 2:
                y += speed;
                break;
            case 3:
                x -= speed;
                break;
         }
            System.out.println("x="+x+"y="+y);
            if (!(y>=0&&y<=900&&x>=0&&x<=900)){
                System.out.println("炮弹无了");
                loop=false;
                break;
            }
       }
    }
}
